home *** CD-ROM | disk | FTP | other *** search
- /*==================================================================
- File: MacZStringToolApp.cp
-
- Contains: Primary application class for the Mac ZString tool
- (based on the PowerPlant framework)
-
- Written by: Eric Traut
-
- Copyright: 2000-2001 Connectix Corporation
-
- This source has been placed into the public domain by
- Connectix Corporation. You have the right to modify,
- distribute or use this code without any legal limitations
- or finanicial/licensing requirements. Connectix is not
- liable for any problems that result from the use of this
- code.
-
- If you have comments, feedback, questions, or would like
- to submit bug fixes or updates to this code, please email
- opensource@connectix.com.
- ==================================================================*/
-
- #include "MacZStringToolApp.h"
-
- #include <LGrowZone.h>
- #include <PP_Messages.h>
- #include <PP_Resources.h>
- #include <UDrawingState.h>
- #include <UMemoryMgr.h>
- #include <URegistrar.h>
- #include <UEnvironment.h>
-
- #include <UControlRegistry.h>
-
- #include "MacZStringWindow.h"
- #include "FileIconPane.h"
- #include "FileSelectionGroupView.h"
-
- #include <Appearance.h>
-
-
- // Constant declarations
- const ResIDT PPob_SampleWindow = 128;
-
-
- // ===========================================================================
- // • main
- // ===========================================================================
-
- int main()
- {
- // Set Debugging options
- SetDebugThrow_(debugAction_Alert);
- SetDebugSignal_(debugAction_Alert);
-
- // Initialize Memory Manager. Parameter is the number of
- // master pointer blocks to allocate
- InitializeHeap(3);
-
- // Initialize standard Toolbox managers
- UQDGlobals::InitializeToolbox(&qd);
-
- // Install a GrowZone to catch low-memory situations
- new LGrowZone(20000);
-
- // Create the application object and run
- MacZStringToolApp theApp;
- theApp.Run();
-
- return 0;
- }
-
-
- // ---------------------------------------------------------------------------
- // • MacZStringToolApp [public]
- // ---------------------------------------------------------------------------
- // Application object constructor
-
- MacZStringToolApp::MacZStringToolApp()
- {
- // Register ourselves with the Appearance Manager
- if (UEnvironment::HasFeature(env_HasAppearance))
- ::RegisterAppearanceClient();
-
- RegisterClasses();
- }
-
-
- // ---------------------------------------------------------------------------
- // • ~MacZStringToolApp [public, virtual]
- // ---------------------------------------------------------------------------
- // Application object destructor
-
- MacZStringToolApp::~MacZStringToolApp()
- {
- // Nothing
- }
-
-
- // ---------------------------------------------------------------------------
- // • StartUp [protected, virtual]
- // ---------------------------------------------------------------------------
- // Perform an action in response to the Open Application AppleEvent.
- // Here, issue the New command to open a window.
-
- void
- MacZStringToolApp::StartUp()
- {
- ObeyCommand(cmd_New, NULL);
- }
-
-
- // ---------------------------------------------------------------------------
- // • ObeyCommand [public, virtual]
- // ---------------------------------------------------------------------------
- // Respond to Commands. Returns true if the Command was handled, false if not.
-
- Boolean
- MacZStringToolApp::ObeyCommand(
- CommandT inCommand,
- void* ioParam)
- {
- Boolean cmdHandled = true; // Assume we'll handle the command
-
- switch (inCommand)
- {
- case cmd_New:
- LWindow* theWindow = LWindow::CreateWindow(PPob_SampleWindow, this);
- ThrowIfNULL_(theWindow);
-
- theWindow->Show();
- break;
-
- default:
- cmdHandled = LApplication::ObeyCommand(inCommand, ioParam);
- break;
- }
-
- return cmdHandled;
- }
-
-
- // ---------------------------------------------------------------------------
- // • FindCommandStatus [public, virtual]
- // ---------------------------------------------------------------------------
- // Determine the status of a Command for the purposes of menu updating.
-
- void
- MacZStringToolApp::FindCommandStatus(
- CommandT inCommand,
- Boolean& outEnabled,
- Boolean& outUsesMark,
- UInt16& outMark,
- Str255 outName)
- {
- switch (inCommand)
- {
- case cmd_New:
- outEnabled = true;
- break;
-
- default:
- LApplication::FindCommandStatus(inCommand, outEnabled,
- outUsesMark, outMark, outName);
- break;
- }
- }
-
-
- // ---------------------------------------------------------------------------
- // • RegisterClasses [protected]
- // ---------------------------------------------------------------------------
- // To reduce clutter within the Application object's constructor, class
- // registrations appear here in this seperate function for ease of use.
-
- void
- MacZStringToolApp::RegisterClasses()
- {
- // Register core PowerPlant classes.
- RegisterClass_(LWindow);
- RegisterClass_(MacZStringWindow);
- RegisterClass_(FileIconPane);
- RegisterClass_(FileSelectionGroupView);
-
- // Register the Appearance Manager/GA classes. You may want
- // to remove this use of UControlRegistry and instead perform
- // a "manual" registration of the classes. This cuts down on
- // extra code being linked in and streamlines your app and
- // project. However, use UControlRegistry as a reference/index
- // for your work, and ensure to check UControlRegistry against
- // your registrations each PowerPlant release in case
- // any mappings might have changed.
-
- UControlRegistry::RegisterClasses();
- }
-
-
-